package application;

import org.apache.wicket.IRequestTarget;
import org.apache.wicket.Request;
import org.apache.wicket.RequestCycle;
import org.apache.wicket.protocol.http.request.WebRequestCodingStrategy;
import org.apache.wicket.request.IRequestCodingStrategy;
import org.apache.wicket.request.IRequestTargetMountsInfo;
import org.apache.wicket.request.RequestParameters;
import org.apache.wicket.request.target.coding.IRequestTargetUrlCodingStrategy;

/**
 * Set Ajax coding strategy.
 */
public class AjaxCodingStrategy implements IRequestCodingStrategy, IRequestTargetMountsInfo {

    private WebRequestCodingStrategy strategy;

    public AjaxCodingStrategy() {
        strategy = new WebRequestCodingStrategy();
    }

    public RequestParameters decode(final Request arg0) {
        RequestParameters params = strategy.decode(arg0);
        params.setOnlyProcessIfPathActive(false);
        return params;
    }

    public CharSequence encode(final RequestCycle arg0, final IRequestTarget arg1) {
        return strategy.encode(arg0, arg1);
    }

    public String rewriteStaticRelativeUrl(final String arg0) {
        return strategy.rewriteStaticRelativeUrl(arg0);
    }

    public void addIgnoreMountPath(final String arg0) {
        strategy.addIgnoreMountPath(arg0);
    }

    public void mount(final IRequestTargetUrlCodingStrategy arg0) {
        strategy.mount(arg0);
    }

    public CharSequence pathForTarget(final IRequestTarget arg0) {
        return strategy.pathForTarget(arg0);
    }

    public IRequestTarget targetForRequest(final RequestParameters arg0) {
        return strategy.targetForRequest(arg0);
    }

    public void unmount(final String arg0) {
        strategy.unmount(arg0);
    }

    public IRequestTargetUrlCodingStrategy urlCodingStrategyForPath(final String arg0) {
        return strategy.urlCodingStrategyForPath(arg0);
    }

    public IRequestTargetUrlCodingStrategy[] listMounts() {
        return strategy.listMounts();
    }
}

